#ifndef VIDEODEVICE_H
#define VIDEODEVICE_H

#include <QObject>
#include <QCameraViewfinderSettings>
#include <QVideoProbe>
#include <QVideoFrame>
#include <QCameraViewfinder>
#include <QCameraInfo>
#include <QCamera>
#include <QTimer>
#include <QMutex>
#include <QSemaphore>

class VideoDevice : public QObject
{
    Q_OBJECT
public:
    explicit VideoDevice(QCameraViewfinder * viewFinder, QObject *parent = nullptr);
    ~VideoDevice(void);

    int get_width(){ return 1920; }
    int get_height(){ return 1080; }

private:
    void setCamera(const QCameraInfo &cameraInfo);
    void openCamera(void);

private slots:
    void updateCameraState(QCamera::State);
    void displayCameraError(void);
    void onProbeFrameSlot(const QVideoFrame &frame);

    void onTimerout(void);
signals:

private:
    QCamera * m_camera;
    QCameraViewfinder * m_viewFinder;
    QVideoProbe * m_videoProbe;

    QMutex lock;
    QTimer * videoTime;
    int timeCnt = 0;

public:
    unsigned char *yuv_buffer;
    size_t yuv_buffer_len;
};

#endif // VIDEODEVICE_H
